/*Bubble Sort Algorithm*/
#include "define.h"
int bubble_sort (int a[]) 
{
/* The first for loop we don't go as far as the last element. The max value of
 * expression is (n-2) > (n-1)
 */
 	int i, j, t, steps = 0, cont = TRUE, found = FALSE;
	for(j = 0; cont && j < ARRAYSIZE-1; j++){ 	//Here we don't go as far
		cont = FALSE;			//as the last element
		for(i = 0; i < ARRAYSIZE-j-1; i++){	
			steps++;
/*			print_array(a);*/
			if(a[i] > a[i + 1]){	//Max value of expression
				t = a[i];	//is (n-2)>(n-1)
				a[i] = a[i + 1];
				a[i + 1] = t;
				cont = TRUE;
			}
		}
	}
	return steps;
}	
